<template>
    <div id="AsnDetailList">
        <div class="detail">
            <component :data="{detailData,argument}" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
    import tableTitle from "commons/TableTitle";
    import navMenu from "commons/NavMenu";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "DetailList",
        mixins: [baseMixin],
        data() {
            return {
                newFlag: false,
                detailsFlag: false,
                argument: {},
                detailData: {},
                selectData: [],
                detailNav: "1",
                componentConfig: [
                    {
                        name: "Table",
                        label: "table",
                        component: () => import('./page/Table.vue')
                    },
                    {
                        name: "particulars",
                        label: "particulars",
                        component: () => import('./page/particulars.vue')
                    }
                ]
            }
        },
        computed: {
            currentComponent() {
                return this.componentConfig[this.detailNav - 1].component;
            }
        },
        methods: {
            //选中的数据
            setSelectData(data) {
                this.$emit("setSelectData", data)
            },
            //返回试图
            backList() {
                this.detailNav = "1";
                this.detailsFlag = false;
            }
        },
        mounted() {
            this.newFlag = this.$store.state.newFlag;
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.argument = data.routeData;
                this.detailData = data.detailList;
                this.detailNav = data.detailListNav;
                this.detailsFlag = data.detailListFlag;
            } else if (this.newFlag) {
                this.$api.get('/queryreplenishkey').then(res => {
                    
                        this.detailData = {
                            replenishkey: res.data.sequence,
                            storerkey2: "ZZZZZZZZ",
                            loc2: "ZZZZZZZZ",
                            sku2: "ZZZZZZZZ",
                            area2: "ZZZZZZZZ"
                        };
                        this.detailNav = "2";
                    
                }).catch(e => {
                    this.$message.error(e);
                })

            } else {
                this.argument = this.$store.state.routeData;
            }

        },
        components: {
            "v-tableTitle": tableTitle,
            "v-navMenu": navMenu,
        },
        watch: {}
    }
</script>

<style>

</style>
